<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The ArrayObject class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="spl.misc.html">« 各种类及接口</a></li>
      <li style="float: right;"><a href="arrayobject.append.html">ArrayObject::append »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="spl.misc.html">各种类及接口</a></li>
    <li>The ArrayObject class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.arrayobject" class="reference">
 <h1 class="title">The ArrayObject class</h1>
 
 
 <div class="partintro"><p class="verinfo">(PHP 5, PHP 7, PHP 8)</p>
 

  <div class="section" id="arrayobject.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    This class allows objects to work as arrays.
   </p>
  </div>

 
  <div class="section" id="arrayobject.synopsis">
   <h2 class="title">类摘要</h2>
 

   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">ArrayObject</strong>
     </span>

     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.iteratoraggregate.html" class="interfacename">IteratorAggregate</a></span><span class="oointerface">,  <a href="class.arrayaccess.html" class="interfacename">ArrayAccess</a></span><span class="oointerface">,  <a href="class.serializable.html" class="interfacename">Serializable</a></span><span class="oointerface">,  <a href="class.countable.html" class="interfacename">Countable</a></span> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 常量 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.arrayobject.html#arrayobject.constants.std-prop-list"><var class="varname">STD_PROP_LIST</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.arrayobject.html#arrayobject.constants.array-as-props"><var class="varname">ARRAY_AS_PROPS</var></a></var>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="arrayobject.construct.html" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type"><span class="type">array</span>|<span class="type">object</span></span> <code class="parameter">$array</code><span class="initializer"> = []</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$iteratorClass</code><span class="initializer"> = ArrayIterator::class</span></span>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.append.html" class="methodname">append</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.asort.html" class="methodname">asort</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = <strong><code>SORT_REGULAR</code></strong></span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.count.html" class="methodname">count</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.exchangearray.html" class="methodname">exchangeArray</a></span>(<span class="methodparam"><span class="type"><span class="type">array</span>|<span class="type">object</span></span> <code class="parameter">$array</code></span>): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.getarraycopy.html" class="methodname">getArrayCopy</a></span>(): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.getflags.html" class="methodname">getFlags</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.getiterator.html" class="methodname">getIterator</a></span>(): <span class="type"><a href="class.iterator.html" class="type Iterator">Iterator</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.getiteratorclass.html" class="methodname">getIteratorClass</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.ksort.html" class="methodname">ksort</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = <strong><code>SORT_REGULAR</code></strong></span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.natcasesort.html" class="methodname">natcasesort</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.natsort.html" class="methodname">natsort</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.offsetexists.html" class="methodname">offsetExists</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$key</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.offsetget.html" class="methodname">offsetGet</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$key</code></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.offsetset.html" class="methodname">offsetSet</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$key</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.offsetunset.html" class="methodname">offsetUnset</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$key</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.serialize.html" class="methodname">serialize</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.setflags.html" class="methodname">setFlags</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.setiteratorclass.html" class="methodname">setIteratorClass</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$iteratorClass</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.uasort.html" class="methodname">uasort</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.uksort.html" class="methodname">uksort</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayobject.unserialize.html" class="methodname">unserialize</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>): <span class="type"><span class="type void">void</span></span></div>

   }</div>
 
  </div>
 
  <div class="section" id="arrayobject.constants">
   <h2 class="title">预定义常量</h2>
   <div class="section" id="arrayobject.constants.flags">
    <h2 class="title">ArrayObject Flags</h2>
    <dl>

     
      <dt id="arrayobject.constants.std-prop-list"><strong><code>ArrayObject::STD_PROP_LIST</code></strong></dt>

      <dd>

       <p class="para">Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.).</p>
      </dd>

     

     
      <dt id="arrayobject.constants.array-as-props"><strong><code>ArrayObject::ARRAY_AS_PROPS</code></strong></dt>

      <dd>

       <p class="para">Entries can be accessed as properties (read and write).</p>
      </dd>

     
    </dl>

   </div>
  </div>
  

 
 </div>
 
 































































































































 
<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="arrayobject.append.html">ArrayObject::append</a> — 追加新的值作为最后一个元素。</li><li><a href="arrayobject.asort.html">ArrayObject::asort</a> — Sort the entries by value</li><li><a href="arrayobject.construct.html">ArrayObject::__construct</a> — Construct a new array object</li><li><a href="arrayobject.count.html">ArrayObject::count</a> — 统计 ArrayObject 内 public 属性的数量</li><li><a href="arrayobject.exchangearray.html">ArrayObject::exchangeArray</a> — Exchange the array for another one</li><li><a href="arrayobject.getarraycopy.html">ArrayObject::getArrayCopy</a> — Creates a copy of the ArrayObject</li><li><a href="arrayobject.getflags.html">ArrayObject::getFlags</a> — Gets the behavior flags</li><li><a href="arrayobject.getiterator.html">ArrayObject::getIterator</a> — Create a new iterator from an ArrayObject instance</li><li><a href="arrayobject.getiteratorclass.html">ArrayObject::getIteratorClass</a> — Gets the iterator classname for the ArrayObject</li><li><a href="arrayobject.ksort.html">ArrayObject::ksort</a> — Sort the entries by key</li><li><a href="arrayobject.natcasesort.html">ArrayObject::natcasesort</a> — Sort an array using a case insensitive &quot;natural order&quot; algorithm</li><li><a href="arrayobject.natsort.html">ArrayObject::natsort</a> — Sort entries using a &quot;natural order&quot; algorithm</li><li><a href="arrayobject.offsetexists.html">ArrayObject::offsetExists</a> — Returns whether the requested index exists</li><li><a href="arrayobject.offsetget.html">ArrayObject::offsetGet</a> — Returns the value at the specified index</li><li><a href="arrayobject.offsetset.html">ArrayObject::offsetSet</a> — 为指定索引设定新值</li><li><a href="arrayobject.offsetunset.html">ArrayObject::offsetUnset</a> — Unsets the value at the specified index</li><li><a href="arrayobject.serialize.html">ArrayObject::serialize</a> — Serialize an ArrayObject</li><li><a href="arrayobject.setflags.html">ArrayObject::setFlags</a> — Sets the behavior flags</li><li><a href="arrayobject.setiteratorclass.html">ArrayObject::setIteratorClass</a> — Sets the iterator classname for the ArrayObject</li><li><a href="arrayobject.uasort.html">ArrayObject::uasort</a> — Sort the entries with a user-defined comparison function and maintain key association</li><li><a href="arrayobject.uksort.html">ArrayObject::uksort</a> — Sort the entries by keys using a user-defined comparison function</li><li><a href="arrayobject.unserialize.html">ArrayObject::unserialize</a> — Unserialize an ArrayObject</li></ul>
</div>
</div></div></body></html>